#include<iostream>
	using namespace std;
#define N 25
int a[N],b[N],c[N];
int n,m,i,j,k;

int main()
{
	cout<<"Introduceti lungimile celor 2 vectori a si b= ";
	cin>>m>>n;

	for(i=1;i<=m;i++)
		{
			cout<<"a["<<i<<"]=";
			cin>>a[i];
		}

	for(i=1;i<=n;i++)
		{
			cout<<"b["<<i<<"]=";
			cin>>b[i];
		}


	i=1;
	j=1;
	k=0;
	while((i<=m)&&(j<=n))
		{
			if(a[i]<b[j])
				{
					k++;
					c[k]=a[i];
					i++;
				}

			else {
				k++;
				c[k]=b[j];
				j++;
				}
	  }
	if(i<=m)
		{
		while(i<=m)
			{
				k++;
				c[k]=a[i];
				i++;
			}

		}

	if(j<=n)
		{
			while(j<=n)
			{
				k++;
				c[k]=b[j];
				j++;
			}
		}
	for(i=1;i<=k;i++)
	cout<<c[i]<<"  "<<endl;
	return 0;
}
